<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>字符串转换整数 (atoi)</title>
</head>
<body>
    <script>
        /**
         * @param {string} s
         * @return {number}
         */
        var myAtoi = function(s) {
            const result = parseInt(s.trim().match(/^[-+]?[0-9]*/g)[0]) || 0;
            if(result>2147483647){
                return 2147483647
            }else if(result < -2147483648){
                return -2147483648
            }else {
                return result
            }
        };

    </script>
</body>
</html>